package org.wattdepot.cli.command;

import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import org.wattdepot.cli.processor.CommandLineInterface;
import static org.junit.Assert.assertTrue;

/**
 * PowerStamp command test case, evaluates command against known values.
 * 
 * @author Bao Huy Ung, Edward Meyer
 */
public class TestPowerStamp extends CommandLineInterface {

  /**
   * Tests if command Powerstamp return valid known values.
   */
  @Test
  public void testPower() {

    List<String> args = new ArrayList<String>();

    boolean powerCheck = false;

    // add first test case Cli command to be passed
    args.add("power");
    args.add("generated");
    args.add("SIM_WAIAU_7");
    args.add("timestamp");
    args.add("2009-11-15T02:00:00.000-10:00");

    PowerStamp power = new PowerStamp();
    String testOut = power.doCommand(args);

    if (testOut.equalsIgnoreCase("8.8E7")) {
      powerCheck = true;
    }

    System.out.println("Sampling known value Source: SIM_WAIAU_7 on 2009-11-15T02:00:00.000-10:00");
    assertTrue("Check SIM_WAIAU_7 on 2009-11-15T02:00:00.000-10:00", powerCheck);

    // pass second known values to as args
    args.set(2, "SIM_WAIAU");
    args.set(4, "2009-11-15T12:13:00.000-10:00");
    testOut = power.doCommand(args);

    if (testOut.equalsIgnoreCase("1.76E8")) {
      powerCheck = true;
    }
    else {
      powerCheck = false;
    }

    System.out.println("Sampling known value Source: SIM_WAIAU on 2009-11-15T12:13:00.000-10:00");
    assertTrue("Check SIM_WAIAU on 2009-11-15T12:13:00.000-10:00", powerCheck);

    // pass third known values as args
    args.set(2, "SIM_OAHU_GRID");
    args.set(4, "2009-11-15T12:13:00.000-10:00");
    testOut = power.doCommand(args);

    if (testOut.equalsIgnoreCase("6.496E8")) {
      powerCheck = true;
    }
    else {
      powerCheck = false;
    }

    System.out.println("Sampling known value Source:"
        + "SIM_OAHU_GRID on 2009-11-15T12:13:00.000-10:00");
    assertTrue("Check SIM_OAHU_GRID on 2009-11-15T12:13:00.000-10:00", powerCheck);

  }

}